<?php 
class bc_model extends CI_Model {
        function __construct()
        {
                parent::__construct();        
                $this->load->helper("local");
                $this->load->helper('date');
                $this->load->database();
        } 
//START-----------------Brocker / Customer-------------------------//              
        function bc_all_brocker_customer()
        {
			$this->load->database();
                $query = $this->db->query('select * from profile order by profile_id DESC');
                $_result =''; $profile_type='';	$priority_code='';$company_name='';$n_name='';$f_name=''; $l_name=''; $cell_phone_num='';$home_phone_num='';$office_phone_num='';$fax_num='';$email_add='';$mc_num='';$comment_box='';
				$_result .=
                "<p class=''><table border='0'><tr><td><a href='".base_url()."bc/add_view_brocker_customer/'><img src='".base_url()."images/icons/action_add.gif' style='border:none'/></a></td><td><a href='".base_url()."bc/add_view_brocker_customer/'>Add New Data</a></td></tr></td></table></p>
                <table width='940' class='Grid' border='1'>
                  <tr>
	 				   <th width='40'><div align='center'>Profile Type</div></th>
                        <th width='40'><div align='center'>Priority Code</div></th>
                        <th width='80'><div align='center'>Company Name</div></th>
                        <th width='40'><div align='center'>Nick Name</div></th>
                        <th width='40'><div align='center'>First Name</div></th>
                        <th width='40'><div align='center'>Last Name</div></th>
						<th width='60'><div align='center'>Mobile Number</div></th>
                        <th width='60'><div align='center'>Home Number</div></th>
                        <th width='60'><div align='center'>Office Number</div></th>
						<th width='50'><div align='center'>Fax Number</div></th>
						<th width='50'><div align='center'>Email</div></th>
                        <th width='40'><div align='center'>MC Number</div></th>
                        <th width='150'><div align='center'>Comment</div></th>
                        <th width='32'><div align='center'></div></th>
                        <th width='24'><div align='center'></div></th>
                        <th width='39'><div align='center'></div></th>
                  </tr>";
				  $_rowClass = 'tr_odd';
                foreach($query->result() as $row)
                {
						
                        if(strlen($row->profile_type)>5 )
                        {
                                $profile_type = substr($row->profile_type,0,5)."...<a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $profile_type = $row->profile_type;}
                        

                        if(strlen($row->priority_code)>5 )
                        {
                                $priority_code = substr($row->priority_code,0,5)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $priority_code = $row->priority_code;}

                        if(strlen($row->company_name)>10 )
                        {
                                $company_name = substr($row->company_name,0,10)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $company_name = $row->company_name;}
						
                        if(strlen($row->n_name)>5 )
                        {
                                $n_name = substr($row->n_name,0,5)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $n_name = $row->n_name;}
						
						 if(strlen($row->f_name)>5 )
                        {
                                $f_name = substr($row->f_name,0,5)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $f_name = $row->f_name;}
						
						 if(strlen($row->l_name)>5 )
                        {
                                $l_name = substr($row->l_name,0,5)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $l_name = $row->l_name;}
						
						 if(strlen($row->cell_phone_num)>7 )
                        {
                                $cell_phone_num = substr($row->cell_phone_num,0,7)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $cell_phone_num = $row->cell_phone_num;}
						
						 if(strlen($row->home_phone_num)>7 )
                        {
                                $home_phone_num = substr($row->home_phone_num,0,7)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $home_phone_num = $row->home_phone_num;}
						
						 if(strlen($row->office_phone_num)>7 )
                        {
                         $office_phone_num = substr($row->office_phone_num,0,7)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $office_phone_num = $row->office_phone_num;}
						
						if(strlen($row->fax_num)>7 )
                        {
                         $fax_num = substr($row->fax_num,0,7)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $fax_num = $row->fax_num;}
						
						if(strlen($row->email_add)>15 )
                        {
                         $fax_num = substr($row->email_add,0,15)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $email_add = $row->email_add;}
						
						if(strlen($row->mc_num)>5 )
                        {
                         $mc_num = substr($row->mc_num,0,5)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $mc_num = $row->mc_num;}
						
						if(strlen($row->comment_box)>10 )
                        {
                         $comment_box = substr($row->comment_box,0,10)."... <a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $comment_box = $row->comment_box;}
						
						
                        $_result.="
					<tr class='".$_rowClass."' ".GetTrEffects().">
						<td><div align='left'>".$profile_type."</div></td>
                        <td><div align='left'>".$priority_code."</div></td>
                        <td><div align='left'>".$company_name."</div></td>
                        <td><div align='left'>".$n_name."</div></td>
                        <td><div align='left'>".$f_name."</div></td>
                        <td><div align='left'>".$l_name."</div></td>
                        <td><div align='left'>".$cell_phone_num."</div></td>
                        <td><div align='left'>".$home_phone_num."</div></td>
                        <td><div align='left'>".$office_phone_num ."</div></td>
                        <td><div align='left'>".$fax_num."</div></td>
						<td><div align='left'>".$email_add."</div></td>
						<td><div align='left'>".$mc_num."</div></td>
						<td><div align='left'>".$comment_box."</div></td>
                        <td width='5'><div align='center'><a href='" .base_url()."bc/view_brocker_customer/".$row->profile_id."'><img src='".base_url()."images/icons/view.gif' style='border:none'/></a></div></td>
                        <td width='5'><div align='center'><a href='".base_url()."bc/edit_brocker_customer/".$row->profile_id."'><img src='".base_url()."images/icons/edit.gif' style='border:none' /></a></div></td>
                        <td width='5'><div align='center'><a href='".base_url()."bc/delete_brocker_customer/".$row->profile_id."'><img src='".base_url()."images/icons/delete.gif' style='border:none' /></a></div></td>
                  </tr>";
				  if($_rowClass=="tr_odd") $_rowClass="tr_even"; else $_rowClass="tr_odd";     
                 }
                        $_result .="</table>"; 
                return($_result);
        }


		
        function add_view_brocker_customer(){
                $_result ="";
           $_result .="<h1>Add Brocker / Customer </h1>";
       					   $_result .="<form method='post' action='".base_url()."bc/p_add_brocker_customer'>";
		                   $_result .="<div align='left' width='100'>Profile_type";
						   $_result .="<textarea rows='1' cols='15' name='txtprofile_type'></textarea> <br/>";	
						   $_result .="<div align='left' width:'100'>Priority_code";
						   $_result .="<textarea rows='1' cols='15' name='txtpriority_code'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Company Name";
						   $_result .="<textarea rows='1' cols='15' name='txtcompany_name'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Nick Name";
						   $_result .="<textarea rows='1' cols='15' name='txtn_name'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>First Name";
						   $_result .="<textarea rows='1' cols='15' name='txtf_name'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Last Name";
						   $_result .="<textarea rows='1' cols='15' name='txtl_name'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Mobile Number";
   						   $_result .="<textarea rows='1' cols='15' name='txtcell_phone_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Home Number";
						   $_result .="<textarea rows='1' cols='15' name='txthome_phone_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Office Number";
						   $_result .="<textarea rows='1' cols='15' name='txtoffice_phone_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Fax Number";
						   $_result .="<textarea rows='1' cols='15' name='txtfax_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Email Address";
						   $_result .="<textarea rows='1' cols='15' name='txtemail_add'></textarea><br/>";
						   $_result .="<div align='left' width:'100'>MC Number";
   						   $_result .="<textarea rows='1' cols='15' name='txtmc_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Comment Box";
						   $_result .="<textarea rows='20' cols='30' name='txtcomment_box'></textarea> <br/> ";
						   $_result .="<br/>
										<table border='0'>
										  <tr>
											<td>
											   <input type='submit' name='cmdsave' value='Save' style='background-image:url(".base_url()."images/icons/save.gif);	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:60px;border:none transparent;color:#0000FF;cursor:pointer;' />
											</td>
											<td>
											</td>
											<td>
											   <input type='submit' name='cmdcancel' value='Cancel' style='background-image:url(".base_url()."images/icons/cancel.gif);	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:70px;border:none transparent;color:#0000FF;cursor:pointer;' />
											</td>
										   </tr>
										 </table>
									   ";
                          
                   $_result .="</div>";
       $_result .="</form>";
           return($_result);
                                        
        }

        function bc_view_brocker_customer($code)
        { 
                $query = $this->db->query("select * from profile where profile_id='$code'");
                $_result ='';
                foreach($query->result() as $row);
                {
								$_result .="<br/><p>".$row->profile_type."</p";
                                $_result .="<br/><p>".$row->priority_code."</p";
								$_result .="<br/><p>".$row->company_name."</p";
								$_result .="<br/><p>".$row->n_name."</p";
								$_result .="<br/><p>".$row->f_name."</p";
								$_result .="<br/><p>".$row->l_name."</p";
								$_result .="<br/><p>".$row->cell_phone_num."</p";
								$_result .="<br/><p>".$row->home_phone_num."</p";
								$_result .="<br/><p>".$row->office_phone_num."</p";
								$_result .="<br/><p>".$row->fax_num."</p";
								$_result .="<br/><p>".$row->email_add."</p";
								$_result .="<br/><p>".$row->mc_num."</p";
								$_result .="<br/><p>".$row->comment_box."</p";
                                $_result .="<div align='right'><table border='0'><tr><td><a href='".base_url()."bc' ><img src='".base_url()."images/icons/back.jpg' style='border:none;'/></a></td><td><a href='".base_url()."bc'>Back to Brocker/Customer List</a></td></te></table></div>";
                        $_result .="</div>";            
                }               
                return($_result);
        }
		
        function bc_edit_brocker_customer($code)
        {        
                $query = $this->db->query("select * from profile where profile_id='$code'");
                $_result ='';
               // $action_url= base_url()."";
                foreach($query->result() as $row);
                {
				$_result .="<form method='post' action='".base_url()."bc/p_edit_brocker_customer/".$row->profile_id."'";
						   $_result .="<div align='left' width='100'>Profile_type";
						   $_result .="<textarea rows='1' cols='15' name='txtprofile_type'>".$row->profile_type."</textarea> <br/>";	
						   $_result .="<div align='left' width:'100'>Priority_code";
						   $_result .="<textarea rows='1' cols='15' name='txtpriority_code'>".$row->priority_code."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Company Name";
						   $_result .="<textarea rows='1' cols='15' name='txtcompany_name'>".$row->company_name."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Nick Name";
						   $_result .="<textarea rows='1' cols='15' name='txtn_name'>".$row->n_name."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>First Name";
						   $_result .="<textarea rows='1' cols='15' name='txtf_name'>".$row->f_name."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Last Name";
						   $_result .="<textarea rows='1' cols='15' name='txtl_name'>".$row->l_name."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Mobile Number";
   						   $_result .="<textarea rows='1' cols='15' name='txtcell_phone_num'>".$row->cell_phone_num."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Home Number";
						   $_result .="<textarea rows='1' cols='15' name='txthome_phone_num'>".$row->home_phone_num."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Office Number";
						   $_result .="<textarea rows='1' cols='15' name='txtoffice_phone_num'>".$row->office_phone_num ."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Fax Number";
						   $_result .="<textarea rows='1' cols='15' name='txtfax_num'>".$row->fax_num."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Email Address";
						   $_result .="<textarea rows='1' cols='15' name='txtemail_add'>".$row->email_add."</textarea><br/>";
						   $_result .="<div align='left' width:'100'>MC Number";
   						   $_result .="<textarea rows='1' cols='15' name='txtmc_num'>".$row->mc_num."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Comment Box";
						   $_result .="<textarea rows='20' cols='30' name='txtcomment_box'>".$row->comment_box."</textarea> <br/> ";
                        
                                       // $_result .="<br/><input type='submit' name='cmdupdate' id='cmdupdate' value='Update' />";
										$_result .="<br/>
													<table>
														<tr>
															<td>
																<input type='submit' name='cmdupdate' value='Update' style='background-image:url(".base_url()."images/icons/edit.gif);
	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:70px;border:none transparent;color:#0000FF;cursor:pointer;' /></td>
															<td></td>
															<td><input type='submit' name='cmdcancel' value='Cancel' style='background-image:url(".base_url()."images/icons/cancel.gif);
	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:70px;border:none transparent;color:#0000FF;cursor:pointer;' /></td>
															
														</tr>
													</table>
													";
                                                                   
                                $_result .="</div>";
                        $_result .="</form>
						"; 
						
                }

                return($_result);
        }
		
	
//---------------END---NEWS------------------------------

/*
//START---------------------------------COMMENT-----------------------------------------------
 function admin_all_comment()
 {
                $query = $this->db->query('select * from comments order by a_code DESC');
                $content='';
                $name='';
                $email_address='';
                
                $_result =              
                "
				<table border='0' style='border-collapse:collapse'>
					<tr>
						<td>
							<a href='".base_url()."bc/add_comment_article/'><img src='".base_url()."images/icons/action_add.gif' style='border:none'/></a>
						</td>
						<td>
							<a href='".base_url()."bc/add_comment_article/'>Add Comment</a>
						</td>
					</tr>
				</table>
				<table class='Grid' width='840' >
                  <tr>
                        <th width='350'>Content</th>
                        <th width='100' align='center'>Name</th>
                        <th width='150'>Email_Address</th>
                        <th width='94'>Date</th>
                        <th></th>                       
                        <th width='24'></th>
                        <th width='39'></th>
						<th></th>
                  </tr>";
                
            $_rowClass = 'tr_odd';
                
                foreach($query->result() as $row)
                {
                        if(strlen($row->Content)>40 )
                        {
                                $_content = substr($row->Content,0,40)." <a href='" .base_url()."bc/view_guest_comment_article/".$row->a_code."'>read more</a>" ;
                        }
                        else{ $_content = $row->Content;}
                        

                        if(strlen($row->Name)>20 )
                        {
                                $_Name = substr($row->Name,0,20)."..." ;
                        }
                        else{ $_Name = $row->Name;}

                        if(strlen($row->Email_Address)>20 )
                        {
                                $_Email = substr($row->Email_Address,0,20)."..." ;
                        }
                        else{ $_Email = $row->Email_Address;}


        				if($row->post=='1')
						{
							$Post='';
							$Unpost="<a href='".base_url()."bc/unpost_c/".$row->a_code."'>Unpost</a>";
						}
						else
						{
							$Post="<a href='".base_url()."bc/post_c/".$row->a_code."'>Post</a>";
							$Unpost="";	
						}
                        $_result .=
                              "<tr class='".$_rowClass ."' ".GetTrEffects() .">
                                        <td align='left'>".$_content. "</td>
                                        <td align='center'>".$_Name."</td>
                                        <td align='left'>".$_Email."</td>
                                        <td align='left'>".$row->Date."</td>
                                        <td align='left'><a href='" .base_url()."bc/view_guest_comment_article/".$row->a_code."'>                                     <img src='".base_url()."images/icons/view.gif' style='border:none'/> </a> </td>
                                        
                                        <td align='left'><a href='".base_url()."bc/delete_guest_comment/".$row->a_code."'>
                                        <img src='".base_url()."images/icons/delete.gif' style='border:none' /></a></td>
										<td align='left'>".$Post."</td>
										<td align='left'>".$Unpost."</td>
                                  </tr>";
                                  
                        if($_rowClass=="tr_odd") $_rowClass="tr_even"; else $_rowClass="tr_odd";        
                                                          
                 }
                        $_result .="</table>"; 
                return($_result);
        }
		function admin_view_comment($value)
        { 
                $query = $this->db->query("select * from comments where a_code='$value'");
                $_result ='';
                foreach($query->result() as $row);
                {
                        $_result .="<div align='left'>";
                                $_result .="<p>".$row->Content."</p>";
                                $_result .="<br/><p>".$row->Name."</p>";
                                $_result .="<br/><p>".$row->Email_Address."</p>";
                                $_result .="<p>".$row->Date."</p>";
								$_result .="<div align='right'><table><tr><td><a href='".base_url()."bc/comment'><img src='".base_url()."/images/icons/back.jpg' style='border:none' /></a></td><td align='center'><a href='".base_url()."bc/comment'>Back to Comments</a></td></tr></table></div>";
                               
                        $_result .="</div>";            
                }               
                return($_result);
        }
		function admin_add_comment()
		{
                $_result ="";
           $_result .="<h1>Add Comment</h1>";
       $_result .="<form method='post' action='".base_url()."bc/p_add_comment'>";
                   $_result .="<div align='left'>";
                           $_result .="<br/>Name:<input type='text' name='Name' />";
						   $_result .="<br/>Email Address:<input type='text' name='EmailAddress' />";
                           $_result .="<br/><br/><br/>Your Comment<br/><textarea rows='20' cols='30' name='Content'></textarea>";
						   $_result .="<br/>
													<table border='0'>
														<tr>
															<td>
																<input type='submit' name='cmdsave' value='Save' style='background-image:url(".base_url()."images/icons/save.gif);
	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:60px;border:none transparent;color:#0000FF;cursor:pointer;' /></form></td>
															
															<td></td>
															<td><form method='post' action='".base_url()."bc/comment'><input type='submit' name='cmdcancel' value='Cancel' style='background-image:url(".base_url()."images/icons/cancel.gif);
	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:70px;border:none transparent;color:#0000FF;cursor:pointer;' /></form></td>
															
														</tr>
													</table>
													";
                          
                   $_result .="</div>";
       $_result .="";
           return($_result);
                                        
        }*/
//END-------------------------------------END-------------------------------------------------
}
?>
